
use if year == 2000 using "$dir/data/interim/occ_by_ind_weights_by_year.dta" , clear
 //this gives us the occ weights for each industry in the 2000 nation-wide distro

ren occ2010 census2010

drop occ_ nonoas total occ_share_oas year

joinby census2010   using "$dir/data/interim/mean_tech_by_cz_census_2016_collapsed.dta" //restricted data


 save "$dir/data/interim/mean_tech_by_cz_by_occ_by_ind_2000.dta", replace



*constructing the instrument:
gen instrument_mean_ind_2000 = mean_count_tech_oth_czs * occ_share // for each czone, gives a tech value weighted by historic nation-wide occ share for the ind

collapse (sum) instrument_mean_ind_2000 , by (year czone ind1990) //adds up to a single predicted tech weight per industry x czone

reshape wide instrument_mean_ind_2000, i(year czone) j(ind)

save "$dir/data/interim/inst_weights_ind_2000.dta", replace




  *do the same for 1970
use if year == 1970 using "$dir/data/interim/occ_by_ind_weights_by_year.dta" , clear

//this gives us the occ weights for each industry in the 2000 nation-wide distro

ren occ2010 census2010

drop occ_ nonoas total occ_share_oas year

joinby census2010   using "$dir/data/interim/mean_tech_by_cz_census_2016_collapsed.dta"


 save "$dir/data/interim/mean_tech_by_cz_by_occ_by_ind_1970.dta", replace


*constructing the instrument:
gen instrument_mean_ind_1970 = mean_count_tech_oth_czs * occ_share // for each czone, gives a tech value weighted by historic nation-wide occ share for the ind

collapse (sum) instrument_mean_ind_1970 , by (year czone ind1990) //adds up to a single predicted tech weight per industry x czone

reshape wide instrument_mean_ind_1970, i(year czone) j(ind)

save "$dir/data/interim/inst_weights_ind_1970.dta", replace



